package com.dao.impl;

import com.dao.UserDao;
import com.neu.dao.BaseDao;

import java.util.List;
import java.util.Map;

public class UserDaoImpl extends BaseDao implements UserDao {
    @Override
    //登录
    public Map<String, Object> login(String name, String pwd) {
        Map<String ,Object> map = null;
        List<Map<String,Object>> list = null;
        String sql="SELECT *\n" +
                "FROM a_user\n" +
                "WHERE a_name = ?\n" +
                "AND a_pwd = MD5(?)";
        list = super.executeQuery(sql,name,pwd);
        if (list.size()>0){
            map = list.get(0);
        }
        return map;
    }

    @Override
    //注册
    public int register(String name, String pwd) {
        int r=0;
        String sql = "INSERT INTO a_user(a_name,a_pwd)\n" +
                "VALUES(?,MD5(?))";
        r= super.executeUpdate(sql,name,pwd);
        return r;
    }
}
